#35.搜索插入位置
def searchInsert(nums, target):
    low = 0
    high = len(nums)-1
    while low <= high:
        mid = (low + high) // 2
        if nums[mid] == target:
            return mid
        if nums[mid] > target:
            high = mid - 1
        else:
            low = mid + 1

    return low

print(searchInsert([1,3,5,6], 4))
print(searchInsert([1,2,3,5,6], 3))
print(searchInsert([1,2,3,5,6], 7))